#!/usr/bin/perl
#
# List persons where the placeid is invalid
#
use FileTable;

$table = shift;
$table = "persons" if !$table;

$file = FileTable::open("db/$table");

@recs = $file->selectany("$table.f_key, $table.placeid, places.type from $table
   left join places on $table.placeid = places.name
   where places.name is null or places.type = 'alias'");
$count = $#recs + 1;
warn "$count records found\n";

for $rec (@recs) {
	print "$$rec{f_key}: $$rec{placeid} ",
	      $$rec{type}?$$rec{type}:"missing",  "\n";
}

    
